<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
	<head>
 <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/CSS/bootstrap.css" />
		<link href="${pageContext.request.contextPath}/CSS/base.css" rel="stylesheet">
		<link href="${pageContext.request.contextPath}/CSS/fileinput.css" rel="stylesheet">
		<link href="${pageContext.request.contextPath}/CSS/animate.min.css" rel="stylesheet">
    <title>图片分享社区 - 首页</title>
  </head>

  <body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container" >
        <div class="navbar-header">
          <a class="navbar-brand" href="fonthead.action">
						<span class="nav-title">图片分享社区</span>
					</a>
        </div>

        <div id="navbar" class="navbar-collapse collapse" >
          <div class="navbar-form navbar-right">
						<li class="dropdown" >
			        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
								<s:if test="#session.IMG==null">
								<img class="img-circle" style="height: 40px;" src="${pageContext.request.contextPath}/IMG/headimg.jpg">
							</s:if>
							<s:else>
							<img class="img-circle" style="height: 40px;" src='<s:property value="#session.IMG"/>'>
							</s:else>
							</a>
						
						<s:if test="#session.ID==null">
			        <ul class="dropdown-menu">
			         <li><a href="loginfont.action">登陆</a></li>
			           <li role="separator" class="divider"></li>
			           <li><a href="registerpage.action">注册</a></li>
			           
			        </ul>
			        </s:if>
			        <s:else>
			         <ul class="dropdown-menu">
 <li><a href="userprofile.action?id=<s:property value="#session.ID"/>">个人主页</a></li>
			          <li role="separator" class="divider"></li>
			              <li><a href="alelterpassword.action">修改密码</a></li>
			           <li role="separator" class="divider"></li>
			          <li><a href="logoutfont.action">注销</a></li>
			        </ul>
			        </s:else>
			      </li>
          </div>
        </div>
      </div>
    </nav>
    <div class="container" style="margin-top:4%;">
    <div class="row">
    <div class="col-md-offset-3 col-md-6 animated swing">
    
    <h3 style="text-align:center;">分享图片</h3>
           <br/>
                    <form class="form-horizontal" method="post" onsubmit="return check()" action="shareresult.action?id=<s:property value='#session.ID'/>" enctype="multipart/form-data">
                       <div class="form-group">
                       <label  class="col-md-4 control-label">主题：</label>
                            <div class="col-md-8">
                          <input type="text" id="title" maxLength="12" name="share.title" class="form-control" placeholder="图片主题" required="required">
                                <br>
                            </div>
                       </div>
                       
                       <div class="form-group">
                       <label  class="col-md-4 control-label">内容：</label>
                            <div class="col-md-8">
                        <textarea class="form-control" id="content" rows="5" cols="10" name="share.content" placeholder="图片描述" required="required"></textarea>
                                <br>
                            </div>
                       </div>
                       
                        <div class="form-group">
                            <label  class="col-md-4 control-label">图片：</label>
                            <div class="col-md-8">
                                <input id="file-0" class="file" type="file" name="image" required="required">
                                <br>
                            </div>
                        </div>
          
                        <div class="form-group">
                       <label  class="col-md-4 control-label">标签：</label>
                            <div class="col-md-8">
                       <select class="form-control" name="share.labelid">
                 <s:iterator value="labellist" id="label">
                       
                  <option value="<s:property value="#label.id"/>"><s:property value="#label.label"/></option>                 
                 </s:iterator>
                              </select>
                                <br>
                            </div>
                       </div>
                          <div class="form-group">
                         <div class="col-md-6"></div>
                            <div class="col-md-4">
                               <button type="submit" class="btn btn-info">分享</button>
                                <a type="button" class="btn btn-info" href="fonthead.action">取消</a>
                                <br>
                            </div>
                              <div class="col-md-2"></div>
                        </div>
                      
                    </form>
                </div>
            </div>

        </div>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="text-align:center;">操作提示</h4>
      </div>
      <div class="modal-body">
                     <h5 style="text-align:center;">请填写完整表单！！！</h5>
      </div>
      <div class="modal-footer">
    
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
   <!--footer-->
<footer>
    <div class="container" style="text-align:center">
        <div class="row">
            <div class="col-md-12">
                <p>
                    Copyright&nbsp;©&nbsp;2012-2015&nbsp;&nbsp;www.sharephoto.com&nbsp;&nbsp;粤ICP备13014270号-4
                </p>
            </div>
        </div>
    </div>
</footer>
<!--footer-->
		<script src="${pageContext.request.contextPath}/JS/jquery-1.12.3.min.js"></script>
<script src="${pageContext.request.contextPath}/JS/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/JS/fileinput.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JS/fileinput_locale_zh.js" type="text/javascript"></script>
 <script type="text/javascript">
    $("#file-0").fileinput({
        'allowedFileExtensions' : ['jpg', 'png','gif'],
        showUpload: false,
        maxFilesNum: 1
    });
     function check(){
   if($("#title").val().trim()==""||$("#content").val().trim()==""){
   $("#myModal").modal("show");
   return false;
   }else{
  return true; 
   }
  };
 </script>
  </body>
</html>
